# Tanım: The Glibc package contains the main C library.
# URL: https://www.gnu.org/software/libc/
# Paketçi: milisarge
# Gerekler:

kernelsurum=4.4
isim=glibc
surum=2.23
devir=1

kaynak=(http://www.kernel.org/pub/linux/kernel/v4.x/linux-$kernelversion.tar.xz
	http://www.linuxfromscratch.org/patches/downloads/$isim/glibc-$surum-fhs-1.patch
	http://ftp.gnu.org/gnu/glibc/glibc-$surum.tar.xz glibc.locales.supported )
	
derle() {

# Headers
cd linux-$kernelversion
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
find dest/include \( -name .install -o -name ..install.cmd \) -delete
mkdir -p $PKG/usr/include
cp -rv dest/include/* $PKG/usr/include

cd ../glibc-$surum

patch -Np1 -i ../glibc-$surum-fhs-1.patch

mkdir -v ../glibc-build
cd ../glibc-build

../glibc-$surum/configure --prefix=/usr \
--disable-profile \
--enable-kernel=2.6.32 \
--enable-obsolete-rpc

make || make -j1

# make -k check 2>&1 | tee glibc-check-log
# grep Error glibc-check-log

make install_root=$PKG install
rm -rf $PKG/usr/share/info/dir

mkdir -p $PKG/etc
cp -v ../glibc-$surum/nscd/nscd.conf $PKG/etc/nscd.conf
mkdir -pv $PKG/var/cache/nscd

touch $PKG/etc/ld.so.conf

mkdir -pv $PKG/usr/lib/locale

cp $SRC/glibc.locales.supported \
../glibc-$surum/localedata/SUPPORTED

make install_root=$PKG localedata/install-locales

cat > $PKG/etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

hosts: files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF


cat > $PKG/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/lib
/lib64
/usr/lib
/usr/lib64
/usr/local/lib
/usr/local/lib64

# Add an include directory
include /etc/ld.so.conf.d/*.conf
# End of  /etc/ld.so.conf
EOF

if [ "`uname -m`" == "i686" ];then
	cat > $PKG/etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/lib
/usr/lib
/usr/local/lib

# Add an include directory
include /etc/ld.so.conf.d/*.conf
# End of  /etc/ld.so.conf
EOF
fi

mkdir $PKG/etc/ld.so.conf.d
}
